from django.urls import path, register_converter
from . import views
from utils.converters import MobileConverter

# 注册mobile转换器
register_converter(MobileConverter, 'mobile')

urlpatterns = [
    # 判断用户名是否重复
    path('usernames/<username:username>/count/',views.UsernameCountView.as_view()),
    # 注册
    path('register/',views.RegisterView.as_view()),
    # 登录
    path('login/',views.LoginView.as_view()),
    # 退出登录
    path('logout/',views.LogoutView.as_view()),
    # 获取登录用户信息
    path('info/',views.CenterView.as_view()),
    # 判断手机是否重复注册
    path('mobiles/<mobile:mobile>/count/',views.MobileCountView.as_view()),
    # 邮箱
    path('emails/',views.EmailView.as_view()),
    # 激活邮箱
    path('emails/verification/',views.EmailVerifyView.as_view()),
    # 新增地址
    path('addresses/create/',views.AddressCreateView.as_view()),
    # 修改地址
    path('addresses/',views.AddressView.as_view()),
    # 修改和删除地址
    path('addresses/<int:address_id>/',views.UpdateDestroyAddressView.as_view()),
    # 修改默认地址
    path('addresses/<int:address_id>/default/',views.DefaultAddressView.as_view()),
    # 修改地址标题
    path('addresses/<int:address_id>/title/',views.UpdateTitleAddressView.as_view()),
    # 修改密码
    path('password/',views.ChangePasswordView.as_view()),
    # 商品点击历史记录
    path('browse_histories/',views.UserHistoryView.as_view()),
]